<%--
  Created by IntelliJ IDEA.
  User: Albert Lee
  Date: 2020/5/25
  Time: 9:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" import="java.sql.*"%>
<%
    request.setCharacterEncoding("utf-8");
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    String id= request.getParameter("id");
    Class.forName("com.mysql.cj.jdbc.Driver");
//桥接
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/demo","root","123456");
//连接数据库

    String sql = "UPDATE user SET"+" username='"+username+"',"+"password='"+password+"'"+ " WHERE (`id` = ?)";
    Statement statement=con.createStatement();
//语句对象
//String sql = "select * from admin where name='"+ name +"'and pwd='"+ pwd + "'";
//ResultSet rs=statement.executeQuery(sql);
    PreparedStatement ps = con.prepareStatement(sql);
    ps.setString(1,id);
//ps.setString(2,username);
//ps.setString(3,password);
    ps.executeUpdate();

    con.close();
    response.sendRedirect("updateuser.jsp");
%>
